package cn.xuchunh.campusbbs.crash;


import cn.xuchunh.campusbbs.AppContext;
import cn.xuchunh.campusbbs.support.acache.ACache;

public class CrashReporter extends Thread {

	private static final String PARAMS_USERNAME = "username";
	private static final String PARAMS_NAME = "name";
	private static final String PARAMS_APP_VERSIONNAME = "appversionname";
	private static final String PARAMS_APP_VERSINCODE = "appversioncode";
	private static final String PARAMS_TIME = "time";
	private static final String PARAMS_ANDROID_VERSION = "androidversion";
	private static final String PARAMS_BRAND = "brand";
	private static final String PARAMS_PRODUCT = "product";
	private static final String PARAMS_STACK = "stacktrace";
	private static final String PARAMS_TOTAL_MEMORY = "totalmem";
	private static final String PARAMS_AVAILABLE_MEMORY = "availblemem";

	@Override
	public void run() {
		ACache cache = AppContext.getInstance().getCache();
		CrashData data = (CrashData) cache
				.getAsObject(CrashDataFactory.CRASHDATA_CACHE);
		if (data != null) {
//			String url = "";
//			try {
//				Caller.doPost(
//						url,
//						new BasicNameValuePair(PARAMS_USERNAME, data
//								.getUserName()),
//						new BasicNameValuePair(PARAMS_NAME, data.getName()),
//						new BasicNameValuePair(PARAMS_APP_VERSIONNAME, data
//								.getAppVersion()),
//						new BasicNameValuePair(PARAMS_APP_VERSINCODE, data
//								.getAppCode()),
//						new BasicNameValuePair(PARAMS_TIME, data.getTime()),
//						new BasicNameValuePair(PARAMS_ANDROID_VERSION, data
//								.getAndroidVerison()),
//						new BasicNameValuePair(PARAMS_BRAND, data.getBrand()),
//						new BasicNameValuePair(PARAMS_PRODUCT, data
//								.getProduct()),
//						new BasicNameValuePair(PARAMS_STACK, data.getStack()),
//						new BasicNameValuePair(PARAMS_TOTAL_MEMORY, data
//								.getTotalMem()), new BasicNameValuePair(
//								PARAMS_AVAILABLE_MEMORY, data.getAvailbleMem()));
//			} catch (CommException e) {
//				// do nothing
//			}
			cache.remove(CrashDataFactory.CRASHDATA_CACHE);
		}
	}
}
